package com.view.czm.androidrecyclerviewcard;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.widget.LinearLayoutManager;
import android.widget.Toast;

import com.czm.cardgllery.CardScaleHelper;
import com.czm.cardgllery.ICurrentItemChanged;
import com.czm.cardgllery.SpeedRecyclerView;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends Activity {

    private SpeedRecyclerView mRecyclerView;
    private List<Integer> mList = new ArrayList<>();
    private CardScaleHelper mCardScaleHelper = null;
    private CardAdapter mCardAdapter=null;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        init();
        for (int i = 0; i < 1; i++) {
            mList.add(R.drawable.pic4);
            mList.add(R.drawable.pic5);
            mList.add(R.drawable.pic6);
        }
        mCardAdapter.notifyDataSetChanged();
        mCardScaleHelper.updateItemCount(mCardAdapter.getItemCount());
    }
    private void init() {
        mRecyclerView = (SpeedRecyclerView) findViewById(R.id.recyclerView);
        mRecyclerView.setflingScale(0.6f);
        final LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
        mRecyclerView.setLayoutManager(linearLayoutManager);

        // mRecyclerView绑定scale效果
        mCardScaleHelper = new CardScaleHelper();
       // mCardScaleHelper.setCurrentItemPos(2);
        //先设置Adapter 再去设置scale的一些效果
        mCardAdapter=new CardAdapter(mList,mCardScaleHelper);
        mRecyclerView.setAdapter(mCardAdapter);
        mCardScaleHelper.addCurrentItemChanged(new ICurrentItemChanged() {
            @Override
            public void onCurrentItemChange(int postion) {
                Toast.makeText(MainActivity.this,String.valueOf(postion), Toast.LENGTH_SHORT).show();
            }
        });
        mCardScaleHelper.attachToRecyclerView(mRecyclerView);
        mCardScaleHelper.Carousel(3000);

    }
}
